<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    body,
    html {
      width: 100%;
    }

    .banner {
      position: relative;
    }

    footer {
      height: 500px;
      width: 100%;
    }

    img {
      width: 100%;
    }

    .box {
      width: 100%;
      height: 100%;
      position: fixed;
      background-color: rgba(255, 255, 255, 0.5);
      top: 0;
      left: 0;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .box .form {
      background-color: white;
      border: 1px solid #ccc;
      width: 500px;
      height: 400px;
      padding: 10px 40px;
      box-sizing: border-box;
      text-align: center;
    }

    .box .form p {
      display: flex;
      width: 350px;
      justify-content: space-between;
      margin: 0px auto;
    }

    .form h2 {
      line-height: 70px;
    }

    .box .form p input {
      border: 1px #aaa solid;
      border-radius: 4px;
      background: 0 0;
      text-align: left;
      font-size: 20px;
      width: 238px;
      height: 35px;
      line-height: 50px;
      padding: 0 10px;
      margin-left: 10px;
    }

    .box .form p span {
      font-size: 20px;
      line-height: 35px;
      color: rgb(85, 85, 85);
      font-weight: bold;
    }

    .box .form input {
      width: 350px;
      height: 40px;
      border-radius: 10px;
      border: 0;
      font-size: 20px;
      background-color: dodgerblue;
    }

    h3 {
      height: 28px;
    }
  </style>
</head>

<body>
  <div class="banner">
    <img
      src="../img/src=http___img.rsdbox.cn_d_file_p_2021-11-06_367baf00c602e3843fedd98aefa40fa3.jpg&refer=http___img.rsdbox.webp"
      alt="">
    <div class="box">
      <div class="form">
        <h2>欢迎注册英雄联盟</h2>
        <p>
          <span>用户名</span>
          <input type="text" placeholder="请输入账号..." id="username">
        <h3 class="nameh3"></h3>
        </p>
        <p>
          <span>手机号</span>
          <input type="text" placeholder="请输入手机号..." id="phone">
        <h3 class="phh3"></h3>
        </p>
        <p>
          <span>身份证号</span>
          <input type="text" placeholder="请输入身份证号..." id="userID">
        <h3 class="idh3"></h3>
        </p>
        <p>
          <span>邮箱</span>
          <input type="text" placeholder="请输入邮箱..." id="email">
        <h3 class="emh3"></h3>
        </p>
        <input type="submit" value="注册" id="btn">
      </div>
    </div>
  </div>
  <footer></footer>

  <script src="../js/(作业)表单验证.js"></script>
  <script>
    var btnEle = document.querySelector('#btn');

    var nameEle = document.querySelector('#username');
    var nameh3Ele = document.querySelector('.nameh3');

    var phoneEle = document.querySelector('#phone');
    var phh3Ele = document.querySelector('.phh3');

    var userIDEle = document.querySelector('#userID');
    var idh3Ele = document.querySelector('.idh3');

    var emailEle = document.querySelector('#email');
    var emh3Ele = document.querySelector('.emh3');
    // 用户名验证
    nameEle.onchange = function () {
      myname();
    }
    // 手机号验证
    phoneEle.onchange = function () {
      phone();
    }
    // 身份证验证
    userIDEle.onchange = function () {
      userId();
    }
    // 邮箱
    emailEle.onchange = function () {
      email();
    }
    btnEle.onclick = function () {
      if (myname() && phone() && userId() && email()) {
        alert('恭喜注册成功');
      } else {
        alert('请填写正确的信息');
      }
    }
  </script>

</body>

</html>